 $.ajaxSetup ({
                            cache: false //关闭AJAX相应的缓存
        }); 
var speed=500;
function divShowHideCss(type,isAdd){
    if(!isAdd){
        if(type==1){
            $("#newcinemaicon").removeClass("newcinemaicon_hover");
            $("#newcinemaicon > p").removeClass("newnav-frp");
            $("#newcinemaicon > p > b").removeClass("newnav-frb");
        }else{
            $("#newmovieicon").removeClass("newcinemaicon_hover");
            $("#newmovieicon > p").removeClass("newnav-frp");
            $("#newmovieicon > p > b").removeClass("newnav-frb");
        }
    }else{
        if(type==1){
            $("#newcinemaicon").addClass("newcinemaicon_hover");
            $("#newcinemaicon > p").addClass("newnav-frp");
		    $("#newcinemaicon > p > b").addClass("newnav-frb");
        }else{
            $("#newmovieicon").addClass("newcinemaicon_hover");
			$("#newmovieicon > p").addClass("newnav-frp");
		    $("#newmovieicon > p > b").addClass("newnav-frb");
        }
    }
}



function cm_divShowHide(tyin){
    //影院显示
    $("#newcinemaicon").click(function(event) {
        if($(tyin).css('display')=='block'){
            divShowHideCss(1,false);
            $(tyin).fadeOut(speed);
        }else{
            $("#citysel").hide(speed);
            divShowHideCss(2,false);
            $('#xlmovie2').fadeOut(speed);
            divShowHideCss(1,true);
            $(tyin).fadeIn();
            event.stopPropagation();
            $(document).unbind('click').click(function(event){
                divShowHideCss(1,false);
                $(tyin).fadeOut(speed);
            });
        }
    });
	
    $(tyin).hover(function(){
        $(document).unbind('click');
    },function(){
        $(document).click(function(event){
            divShowHideCss(1,false);
            $(tyin).fadeOut(speed);
        });
    });
    
    $("#newmovieicon").click(function(event) {
        if($('#xlmovie2').css('display')=='block'){
            divShowHideCss(2,false);
            $('#xlmovie2').fadeOut(speed);
        }else{
            $("#citysel").hide(speed);
            divShowHideCss(1,false);
            $(tyin).fadeOut(speed);
            divShowHideCss(2,true);
            $('#xlmovie2').fadeIn();
            event.stopPropagation();
            $(document).unbind('click').click(function(event){
                divShowHideCss(2,false);
                $('#xlmovie2').fadeOut(speed);
            });
        }
    });
	
    $('#xlmovie2').hover(function(){
        $(document).unbind('click');
    },function(){
        $(document).click(function(event){
            divShowHideCss(2,false);
            $('#xlmovie2').fadeOut(speed);
        });
    });
}
var cyid=1,cid;
var ycityid=0;
$(document).ready(function() {
    ycityid = getCookie("ztyingonde");
    var tyin ;
    if (typeof (ycityid) != "undefined" && ycityid != null && ycityid != 0) {
        //alert(ycityid);
        cid = ycityid;
        tyin = "#ycl" + ycityid;
        //$(tyin).show();
        $(tyin+" em").html($(tyin+" ul a").length);
        var cityn = "合肥";
        switch (ycityid) {
            case "1":
                cityn = "合肥";
                break;
            case "2":
                cityn = "上海";
                break;
            case "3":
                cityn = "深圳";
                break;
            case "4":
                cityn = "广州";
                break;
            case "5":
                cityn = "武汉";
                break;
        }
        $("#h2city").html(cityn);
        cm_divShowHide(tyin);
    }
    else {
        $.ajax({ type: 'POST', url: '/AjaxCMS/ajax_IPcity.html', data: '', success: function(data) {
            if (data == "合肥") {
                cyid = 1;
            }

            if (data == "芜湖") {
                cyid = 2;
            }
            if (data == "天津") {
                cyid = 8;
            }
            if (data == "广州") {
                cyid = 4;
            }
            if (data == "武汉") {
                cyid = 5;
            }
            if (data == "杭州") {
                cyid = 6;
            }
            if (data == "昆明") {
                cyid = 7;
            }
            if (data == "深圳") {
                cyid = 3;
            }
            if (data == "西安") {
                cyid = 12;
            }
            if (data == "石家庄") {
                cyid = 15;
            }
            if (data == "成都") {
                cyid = 16;
            }
            if (data == "十堰") {
                cyid = 18;
            }
            if (data == "沈阳") {
                cyid = 19;
            }
            if (data == "南京") {
                cyid = 17;
            }
            if (data == "常熟") {
                cyid = 20;
            }
            if (data == "青岛") {
                cyid = 14;
            }
            if (data == "太原") {
                cyid = 21;
            }
            if (data == "绍兴") {
                cyid = 23;
            }
            if (data == "唐山") {
                cyid = 22;
            }
            if (data == "周口") {
                cyid = 35;
            }
            if (data == "仪征") {
                cyid = 37;
            }
            if (data == "清远") {
                cyid = 38;
            }
            if (data == "厦门") {
                cyid = 39;
            }
            if (data == "东莞") {
                cyid = 24;
            }
            if (data == "昆山") {
                cyid = 34;
            }
            if (data == "苏州") {
                cyid = 25;
            }
            if (data == "福州") {
                cyid = 40;
            }
            else {
                data = "合肥";
                cyid = 1;
            }
            cid = cyid;
            tyin = "#ycl" + cyid;
            //$(tyin).show();


            $("#h2city").html(data);
            cm_divShowHide(tyin);
        }
        });
    }
    //首页显示合肥
    
    if(window.location.href=="http://www.inpiao365.com/")
    {
       $("#h2city").html("合肥");
       $("#ycl1").siblings().hide();
    }
    if(typeof(cid)!="undefined" && cid!=null&& cid!="")
    {
        $("#xlmovie2").load("/xmldata/cityTodayMovie/" + cid + ".html");
    }
    else
    {
        $("#xlmovie2").load("/xmldata/cityTodayMovie/1.html");
    }

    $("#tipsclose").click(function() {
        $("#tips").hide();
    })

    $("#cinemaclose").click(function() {
        $("#cinemalist").hide();
        $("#foldcinema").removeClass("cinemaicon-on").addClass("cinemaicon");

    })
    $("#movieclose").click(function() {
        $("#movielist").hide();
        $("#foldmovie").removeClass("movieicon-on");
    })
    $("#foldcinema").toggle(function() {
          $(this).addClass("cinemaicon-on");
          $("#cinemalist").show();
    },function() {
          $(this).removeClass("cinemaicon-on");
          $("#cinemalist").hide();
    });
	
    $("#morecolumn").mouseover(function() {
        $("#divmorec").show();
    }).mouseout(function() {
        $("#divmorec").hide();
    });
    
    $("#cityall").click(function(event) {
        if($('#citysel').css('display')=='block'){
            $("#citysel").fadeOut("slow");
        }else{
            $("#citysel").fadeIn("slow");
            event.stopPropagation();
            if($('#xlmovie2').css('display')=='block'){
                divShowHideCss(2,false);
                $('#xlmovie2').fadeOut(speed);
            }
            
            
            if($(tyin).css('display')=='block'){
                divShowHideCss(1,false);
                $(tyin).fadeOut(speed);
            }
            $(document).unbind('click').click(function(event){
                $("#citysel").hide(speed);
            });	 
        }
    });

    $("#citysel").hover(function(){
	    $(document).unbind('click');
    },function(){
	    $(document).click(function(event){
	        $("#citysel").hide();
	    });
    });

})

function hideDiv(){
    
}

function userlogin()
{
	window.location ="/UserCenter/UserLogin.aspx?loginFlag=1&cmsurl="+escape(window.location.href);
}
function userreg()
{
	window.location ="/UserCenter/Register.aspx?RetUrl="+escape(window.location.href);
}

function showgroup(ComID)
{
   var obj=$("#"+ComID).offset();
   $("#divgroup").html('<iframe width="290" height="150" frameborder=0 src="/group/grouplogin.html"></iframe>').show();
   
}
function closediag()
{
	$("#divgroup").hide();
	
	
}
function setCookie(name, value, expires, path)
{
    if(!expires) expires = -1;
    if(!path) path = "/";
    var d = "" + name + "=" + value;

    var e;
    if (expires < 0) {
        e = "";
    }
    else if (expires == 0) {
        var f = new Date(1970, 1, 1);
        e = ";expires=" + f.toUTCString();
    }
    else {
        var now  = new Date();
        var f = new Date(now.getTime()  + expires*60*60*1000);
        e = ";expires=" + f.toUTCString();
    }
    

    document.cookie = name + "=" + value + ";path=" + path + e ;
}


function getCookie(c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=")
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1
            c_end = document.cookie.indexOf(";", c_start)
            if (c_end == -1) c_end = document.cookie.length
            return unescape(document.cookie.substring(c_start, c_end))
        }
    }
    return ""
}

var Cookies = {};
/**//**
 * 设置Cookies
 */
Cookies.set = function (name, value) {
    alert(name);
    var argv = arguments;
    var argc = arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path = (argc > 3) ? argv[3] : '/';
    var domain = (argc > 4) ? argv[4] : null;
    var secure = (argc > 5) ? argv[5] : false;
    document.cookie = name + "=" + escape(value) +
       ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
       ((path == null) ? "" : ("; path=" + path)) +
       ((domain == null) ? "" : ("; domain=" + domain)) +
       ((secure == true) ? "; secure" : "");
};
/**//**
 * 读取Cookies
 */
Cookies.get = function (name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    var j = 0;
    while (i < clen) {
        j = i + alen;
        if (document.cookie.substring(i, j) == arg)
            return Cookies.getCookieVal(j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0)
            break;
    }
    return null;
};
/**//**
 * 清除Cookies
 */
Cookies.clear = function (name) {
    if (Cookies.get(name)) {
        var expdate = new Date();
        expdate.setTime(expdate.getTime() - (86400 * 1000 * 1));
        Cookies.set(name, "", expdate);
    }
};

Cookies.getCookieVal = function (offset) {
    var endstr = document.cookie.indexOf(";", offset);
    if (endstr == -1) {
        endstr = document.cookie.length;
    }
    return unescape(document.cookie.substring(offset, endstr));
};


